CONNECT TO adp@
CREATE PROCEDURE processBufferPool(IN bufferPoolName VARCHAR(10))
LANGUAGE SQL
BEGIN
	DECLARE stmt VARCHAR(100);
	DECLARE recordCount INT DEFAULT 0;

	SELECT COUNT(*) INTO recordCount
	FROM SYSCAT.BUFFERPOOLS
	WHERE bpname = bufferPoolName;

	IF (recordCount = 0)
	THEN
		SET stmt = 'CREATE BUFFERPOOL ' || bufferPoolName || ' IMMEDIATE  SIZE 25000 PAGESIZE 32 K ';
		PREPARE s1 FROM stmt;
		EXECUTE s1;	
	END IF;
END@
call processBufferPool('ADP_POOL')@
DROP PROCEDURE processBufferPool@
CONNECT RESET@
